import java.io.File;
import java.io.FileFilter;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;

import com.albermark.photoorganizer.filefilter.PhotosFileFilter;
import com.albermark.photoorganizer.pojo.Photo;
import com.albermark.photoorganizer.processor.PhotoProcessor;
import com.albermark.photoorganizer.scanner.PhotoFileScanner;


/**
 * 
 * @author Nuno Ferreira
 *
 */
public class PhotoOrganizerStarter {

	public static void main(String[] args) {
		
		BlockingQueue<Photo> photosQueue = new LinkedBlockingQueue<Photo>(20);
		
		File targetRootFolder = new File("C:/Users/Nuno/Pictures/OrganizedPhotos/");
		if (!targetRootFolder.exists()) {
			targetRootFolder.mkdir();
		}
		

		FileFilter fileFilter = new PhotosFileFilter();
		
		PhotoFileScanner[] scanners = new PhotoFileScanner[] {
				  new PhotoFileScanner("Scanner 1", new File("//MYBOOKWORLD/Public/Users/Nuno/Pictures"), fileFilter, photosQueue)
//				, new PhotoFileScanner("Scanner 2", new File("//MYBOOKWORLD/Public/Shared Videos"), fileFilter, photosQueue)
//				, new PhotoFileScanner("Scanner 3", new File("//MYBOOKWORLD/Public/Shared Pictures/MacBookProPictures"), fileFilter, photosQueue)
		};
			
		PhotoProcessor[] processors = new PhotoProcessor[] {
				new PhotoProcessor("Processor 1", targetRootFolder, photosQueue, true),
				new PhotoProcessor("Processor 2", targetRootFolder, photosQueue, true),
				new PhotoProcessor("Processor 3", targetRootFolder, photosQueue, true)
		};
		

		for (Thread thread : scanners) {
			thread.start();
		}
		for (Thread thread : processors) {
			thread.start();
		}
		
		
		try {
			for (Thread thread : scanners) {
				thread.join();
			}
			for (Thread thread : processors) {
				thread.join();
			}
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
}
